package com.ndp.fb.enums.publish;

import java.util.Objects;

import lombok.Getter;

/**
 * Created by Administrator on 2014/10/27.
 */
@Getter
public enum PublishResultType {

    adCreativeSuccess(1),

    adCreativeFail(2),

    campaignGroupSuccess(3),

    campaignGroupFail(4),

    adSetSuccess(5),

    adSetFail(6),

    adGroupSuccess(7),

    adGroupFail(8),

    advertisingFail(9),

    preProcessPublishFail(11);

    /**
     * 防止枚举序列值与Facebook的不能对应而指定index
     */
    private Integer index;

    /**
     * 私有构造方法
     *
     * @param index index
     */
    private PublishResultType(Integer index) {
        this.index = index;
    }

    /**
     * 根据index获取UserAudienceType
     * @param index index
     * @return Status
     */
    public static PublishResultType getPublishResultType(Integer index) {
        for (PublishResultType c : PublishResultType.values()) {
            if (Objects.equals(c.index, index)) {
                return c;
            }
        }
        return null;
    }
}
